package com.t235.gc.operations.controller;

import com.t235.gc.AjaxResult;
import com.t235.gc.entity.Device;
import com.t235.gc.operations.service.DeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/device")
public class DeviceController {
    @Autowired
    DeviceService deviceService;

    @GetMapping("/admin/selectDevice")
    public AjaxResult selectDevice(){
        List<Device> devices = deviceService.selectDevice();
        return AjaxResult.success(devices);
    }

    @GetMapping("/admin/selectLessStockDevice")
    public AjaxResult selectLessStockDevice(){
        List<Device> devices = deviceService.selectLessStockDevice();
        return AjaxResult.success(devices);
    }

    @GetMapping("/admin/selectFaultDevice")
    public AjaxResult selectFaultDevice(){
        List<Device> devices = deviceService.selectFaultDevice();
        return AjaxResult.success(devices);
    }

    @PostMapping("/admin/updateDeviceStatus")
    public AjaxResult updateDeviceStatus(Integer deviceid){
        return AjaxResult.success(deviceService.updateDeviceStatus(deviceid));
    }

    @GetMapping("/admin/selectOutLineDevice")
    public AjaxResult selectOutLineDevice(Integer deviceid){
        List<Device> devices = deviceService.selectOutLineDevice(deviceid);
        return AjaxResult.success(devices);
    }
}
